<div id="menu">
  <ul class="ulMenu">
<?php if ($TARGET->user->display_name() == '') {?>
    <li class="liMenu">
        <a href="/profile/login">Login</a>
    </li>
        <li class="liMenu">
        <a href="/profile/register">Register</a>
    </li>
<?php } else { ?>    
    <li class="liMenu">
        <a href="/messenger">Messenger</a>
    </li>
<?php } ?>

<?php $tmp_static_pages = new pages(0, $TARGET);
      $main_pages = $tmp_static_pages->select($count, array('parentId' =>0 , 'type'=>'page', 'order'=>'`order` ASC'));
?>
<?php foreach($main_pages as $id => $static_page) { ?>
    <li class="liMenu">
        <a href="<?php echo $static_page->data->alias; ?>"><?php echo $static_page->data->menu_title; ?></a>
    </li>
    <?php $childrens_pages = $static_page->get_childrens();
          if (count($childrens_pages)>0) {
              foreach ($childrens_pages as $children_page) { ?>
    <li>&nbsp;<a href="<?php echo $children_page->data->alias; ?>"><?php echo $children_page->data->menu_title; ?></a></li>
<?php }   }   } ?>
</ul>
</div>

